/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src.services.system;

import java.util.List;
import javax.faces.model.ListDataModel;
import org.primefaces.model.SelectableDataModel;
import src.domain.system.Approval;

/**
 *
 * @author Lalugina
 */
public class ApprovalDM extends ListDataModel<Approval> implements SelectableDataModel<Approval> {

    public ApprovalDM() {
    }

    public ApprovalDM(List<Approval> data) {  
        super(data);  
    } 
      
    @Override
    public Object getRowKey(Approval object) {
        return object.getId();  
    }

    @Override
    public Approval getRowData(String rowKey) {
        List<Approval> approvals = (List<Approval>) getWrappedData();  
          
        for(Approval approval : approvals) {  
            if(rowKey.equals(approval.getId().toString()))  
                return approval;  
        }  
          
        return null; 
    }
    
    
}
